package sgt.onlinetest.hibernatedao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;

public class HibernateDAOFactory {

    private static Log log = LogFactory.getLog(HibernateDAOFactory.class);
    /**
     * Creates a standalone IDAOFactory that returns unmanaged DAO
     * beans for use in any environment Hibernate has been configured
     * for. Uses HibernateUtil/SessionFactory and Hibernate context
     * propagation (CurrentSessionContext), thread-bound or transaction-bound,
     * and transaction scoped.
     */
    public static final Class HIBERNATE = HibernateDAOFactory.class;
    private Session session;

    public HibernateDAOFactory() {
        this(HibernateSessionProvider.getNewSession());
    }

    public HibernateDAOFactory(Session session) {
        this.session = session;
    }

    public HibernateTestDAO getTestDAO() {
        return new HibernateTestDAO(session);
    }

    public HibernateRoleDAO getRoleDAO() {
        return new HibernateRoleDAO(session);

    }

    public HibernateUserDAO getUserDAO() {
        return new HibernateUserDAO(session);
    }

    public HibernateQuestionDAO getQuestionDAO() {
        return new HibernateQuestionDAO(session);
    }

    public HibernateQuestionCategoryDAO getQuestionCategoryDAO() {
        return new HibernateQuestionCategoryDAO(session);
    }

    public HibernateTestSessionDAO getTestSessionDAO() {
        return new HibernateTestSessionDAO(session);
    }
}
